package com.giser.testapp.lib.Tool;


import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.giser.testapp.MainActivity;
import com.giser.testapp.lib.App.EnvApplication;

/**
 * Created by Lss on 2017/12/6.
 */

public class AlertUtil {
    public static void createDialog(Context mContext, String title, String mess){
        new AlertDialog.Builder((MainActivity)mContext).setTitle(title).setMessage(mess)
                .setPositiveButton("确定", null).create().show();
    }

    public static void createDialog_GPS(final Context mContext, String title, String mess,final int mtype){
        final AlertDialog.Builder dialog = new AlertDialog.Builder((MainActivity)mContext);
        dialog.setTitle(title);
        dialog.setMessage(mess);
        dialog.setPositiveButton("设置", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                // 转到手机设置界面，用户设置GPS
                SystemSettingUtil.setGPSOpen(mContext);
            }
        });
        dialog.setNeutralButton("取消", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                arg0.dismiss();
                if(mtype==1){
                    ToastUtil.showShort(mContext,"当前为GPS定位，室内信号较弱！");
                }else{
                    ToastUtil.showShort(mContext,"定位服务未开启！");
                }
            }
        });
        dialog.show();
    }

    public static void createDialog_Notify(final Context mContext, String title, String mess){
        final AlertDialog.Builder dialog = new AlertDialog.Builder((MainActivity)mContext);
        dialog.setTitle(title);
        dialog.setMessage(mess);
        dialog.setPositiveButton("设置", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                SystemSettingUtil.setNotify((MainActivity)mContext);
            }
        });
        dialog.setNeutralButton("取消", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                arg0.dismiss();
                ToastUtil.showShort(mContext,"通知服务未开启...");
            }
        });
        dialog.show();
    }

    public static void createDialog_Exit(Context mContext){
        AlertDialog.Builder dialog = new AlertDialog.Builder((MainActivity)mContext);
        dialog.setTitle("友情提示");
        dialog.setMessage("确认退出当前程序？");
        dialog.setPositiveButton("退出", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                EnvApplication.getApplication().Exit();
            }
        });
        dialog.setNeutralButton("取消", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                arg0.dismiss();
            }
        });
        dialog.show();
    }

}

